package leetcode.part2;

import org.junit.Test;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * 困难
 */
public class S76 {
    public String minWindow(String s, String t) {
        String[] sa = s.split("");
        int left=0;
        int right=0;
        Set<String> origin=new HashSet<>();
        Set<String> set=new HashSet<>();
        String[] ts = t.split("");
        for (String e : ts) {
            set.add(e);
            origin.add(e);
        }
        String res=s;
        while (left< sa.length&&right< sa.length){
            while (set.contains(sa[right])&&right< sa.length){
                set.remove(sa[right++]);
            }
            if (set.isEmpty()){
                String tmp= s.substring(left,right);
                if (tmp.length()<res.length()) res=tmp;
                left++;
            }
            if (set.contains(sa[left])){
                set.add(sa[left]);
            }

        }
        return res;

    }
    @Test
    public void test(){
        String s = "ADOBECODEBANC", t = "ABC";
        
    }
}
